package com.slz3.business.module.goodsManagement.gooGoods.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.goodsManagement.gooGoods.domain.GooGoods;
import com.slz3.business.module.goodsManagement.gooGoods.domain.GooGoodsFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class GooGoodsTransactionalServiceImpl implements GooGoodsTransactionalService {

    @Override
    public GooGoods modify(GooGoods gooGoodsNew) {
        Repositorys.gooGoods.test();
        Repositorys.gooGoods.save(GooGoodsFactory.initBaseFields());
        System.err.println(1/0);
        gooGoodsNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.gooGoods.saveAndFlush(gooGoodsNew);
    }

    @Override
    public List<GooGoods> batchModify(List<GooGoods> gooGoodsList) {
        return Repositorys.gooGoods.saveAll(gooGoodsList);
    }
}
